package com.lxk.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.UUID;

/**
 * @author JohnSoybean
 * @create 2020/7/6 16:19
 * @description 验证码生成工具类
 */
public class CodeUtil {

    /**
     * UUID类code
     * @return
     */
    public static String generateUUIDCode() {
        return UUID.randomUUID().toString().replace("-", "");
    }

    /**
     * 6位验证码
     * @return
     */
    public static String generateSixCode() {
        Random random = new Random();
        int intCode = random.nextInt(900000) + 100000;
        return Integer.toString(intCode);
    }

    /**
     * 生成订单编号
     * @return
     */
    public static String generateOrderNumber() {
        Random rand = new Random();
        int str1 = rand.nextInt(8999)+1000;
        DateFormat format = new SimpleDateFormat("yyMMddHHmmssSSS");
        String str2 = format.format(new Date());
        String orderNumber = str2 + str1;
        return orderNumber;
    }

}
